package com.java.module.fire.controller.admin;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.java.common.lang.annotation.Log;
import com.java.common.lang.domain.AjaxResult;
import com.java.common.lang.enums.BusinessTypeEnum;
import com.java.common.utils.WebKit;
import com.java.module.fire.domain.Flollow;
import com.java.module.fire.service.IFlollowService;
import com.java.common.utils.poi.ExcelUtil;
import com.java.common.lang.domain.page.TableDataInfo;

/**
 * 关注用户Controller
 * 
 * @author Administrator
 * @date 2025-02-10
 */
@RestController("AdminFlollowController")
@RequestMapping("/fire/flollow")
public class FlollowController {
    @Autowired
    private IFlollowService flollowService;

    /**
     * 查询关注用户列表
     */
    @PreAuthorize("@ss.hasPermi('fire:flollow:list')")
    @GetMapping("/list")
    public TableDataInfo list(Flollow flollow) {
        WebKit.startPage();
        List<Flollow> list = flollowService.selectFlollowList(flollow);
        return WebKit.getDataTable(list);
    }

    /**
     * 导出关注用户列表
     */
    @PreAuthorize("@ss.hasPermi('fire:flollow:export')")
    @Log(title = "关注用户", businessType = BusinessTypeEnum.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Flollow flollow) {
        List<Flollow> list = flollowService.selectFlollowList(flollow);
        ExcelUtil<Flollow> util = new ExcelUtil<Flollow>(Flollow.class);
        return util.exportExcel(list, "flollow");
    }

    /**
     * 获取关注用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('fire:flollow:query')")
    @GetMapping(value = "/{followId}")
    public AjaxResult getInfo(@PathVariable("followId") Long followId) {
        return AjaxResult.success(flollowService.selectFlollowById(followId));
    }

    /**
     * 新增关注用户
     */
    @PreAuthorize("@ss.hasPermi('fire:flollow:add')")
    @Log(title = "关注用户", businessType = BusinessTypeEnum.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Flollow flollow) {
        return WebKit.toAjax(flollowService.insertFlollow(flollow));
    }

    /**
     * 修改关注用户
     */
    @PreAuthorize("@ss.hasPermi('fire:flollow:edit')")
    @Log(title = "关注用户", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Flollow flollow) {
        return WebKit.toAjax(flollowService.updateFlollow(flollow));
    }

    /**
     * 删除关注用户
     */
    @PreAuthorize("@ss.hasPermi('fire:flollow:remove')")
    @Log(title = "关注用户", businessType = BusinessTypeEnum.DELETE)
	@DeleteMapping("/{followIds}")
    public AjaxResult remove(@PathVariable Long[] followIds) {
        return WebKit.toAjax(flollowService.deleteFlollowByIds(followIds));
    }
}
